# Maintainer: Marcin Sielski <marcin.sielski@motorolasolutions.com>

_realname=openh264
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.4.0
pkgrel=1
pkgdesc="Library for encoding/decoding H264/AVC video streams (mingw-w64)"
arch=('any')
url="http://www.openh264.org/"
license=("BSD")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config" "${MINGW_PACKAGE_PREFIX}-nasm")
depends=()
options=('strip' 'staticlibs')
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/cisco/openh264/archive/v${pkgver}.tar.gz")
sha256sums=('a1b9a7a7f1ee204793c613789a505f0971bc2b03b3dbd8f05d9c4a3f3b900a22')

build() {
  [[ -d "build-${MINGW_CHOST}" ]] && rm -rf "build-${MINGW_CHOST}"
  cp -rf "$srcdir/${_realname}-${pkgver}" "${srcdir}/build-${MINGW_CHOST}"
  cd "build-${MINGW_CHOST}"
  if [[ "${MINGW_CHOST}" == "i686-w64-mingw32" ]]; then
    _arch="i686"
  else
    _arch="x86_64"
  fi
  make ARCH=${_arch} AR=ar OS=mingw_nt
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  if [[ "${MINGW_CHOST}" == "i686-w64-mingw32" ]]; then
    _prefix="mingw32"
  else
    _prefix="mingw64"
  fi
  make DESTDIR="${pkgdir}" PREFIX=${_prefix} install
}
